package com.cleaningcloud.cld.controller;

import com.cleaningcloud.cld.domain.dto.CldAssetsRecordDto;
import com.cleaningcloud.cld.domain.vo.CldAssetsRepairVo;
import com.cleaningcloud.cld.service.ICldAssetsRepairService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资产记录Controller
 *
 * @author cleaningcloud
 * @date 2024-10-06
 */
@RestController
@RequestMapping("/assetsRepair")
public class CldAssetsRepairController extends BaseController {
    @Autowired
    private ICldAssetsRepairService service;


    /**
     * 查询资产维修记录
     */
    @GetMapping("/getRepairList")
    public TableDataInfo getRepairList(CldAssetsRecordDto cldAssetsRepairDto) {
        startPage();
        List<CldAssetsRepairVo> list = service.getRepairList(cldAssetsRepairDto);
        return getDataTable(list);
    }

    /**
     * 查询资产维修记录
     */
    @GetMapping("/getRepairGroupProjectList")
    public TableDataInfo getRepairGroupProjectList(CldAssetsRecordDto cldAssetsRepairDto) {
        startPage();
        List<CldAssetsRepairVo> list = service.getRepairGroupProjectList(cldAssetsRepairDto);
        return getDataTable(list);
    }

    /**
     * 查询资产维修明细记录
     */
    @GetMapping("/getRepairDetailsList")
    public TableDataInfo getRepairDetailsList(CldAssetsRecordDto cldAssetsRepairDto) {
        startPage();
        List<CldAssetsRepairVo> list = service.getRepairDetailsList(cldAssetsRepairDto);
        return getDataTable(list);
    }


    /**
     * 根据资产记录id查询
     */
    @GetMapping("/getRepairDetails/{assetsRecordId}")
    public AjaxResult getRepairDetails(@PathVariable Long assetsRecordId) {
        return success(service.getRepairDetailsByRecordId(assetsRecordId));
    }


    /**
     * 新增资产记录维修
     */
    @PostMapping
    public AjaxResult add(@RequestBody CldAssetsRecordDto cldAssetsRepairDto) {
        return toAjax(service.addAssetsRepair(cldAssetsRepairDto));
    }


}
